This invention relates to an optical sensor, used mainly for determining the partial pressure of O.sub.2 or CO.sub.2 in respiratory gas and wherein a light source is used for radiating excitation light via at least one excitation filter into a measuring chamber containing the sample medium to be analyzed, i.e., a gas or liquid. The flourescence radiation excited in a fluorescence indicator and extinguished or reduced by the medium to be analyzed is transmitted to a photodetector via at least one emission filter. A reference measuring chamber is provided in addition to the measuring chamber, which is also exposed to excitation light from the same light source and is also provided with a fluorescence indicator whose fluorescence radiation is transmitted to a reference photodetector via at least one reference emission filter. The signals of the photodetector and the reference signals of the reference photodetector are fed into an evaluation unit for evaluation relative to each other.